#include <iostream>
// #include "SeqList.h"
#include "SeqList.cpp" /*模板类存在两次编译,所以要引入cpp文件否则会出现函数未引用*/
using namespace std;

struct Teacher
{
        char name[64];
        int age;
};

void seqTeacher(){
        Teacher t1, t2, t3, tmp;
        t1.age = 31;
        t2.age = 32;
        t3.age = 33;

        SeqList<Teacher> list(10);
        list.insert(t1, 0);
        list.insert(t2, 0);
        list.insert(t3, 0);

        //测试链表的遍历
        for (int i = 0; i < 3; i++){
                list.get(i, tmp);
                cout<<tmp.age<<" ";
        }
        cout<<endl;


       list.clear();//清空链表

        list.insert(t1, 0);
        list.insert(t2, 0);
        list.insert(t3, 0);

        //测试链表的销毁
        printf("开始删除元素\n");
        while ( list.getLen() > 0 ){
                list.del(0, tmp);
                cout<<tmp.age<<" ";
        }

        cout<<endl;
}

void seqTeacherPointers()
{
        Teacher t1, t2, t3;
        t1.age = 31;
        t2.age = 32;
        t3.age = 33;

        Teacher *p1, *p2, *p3;
        p1 = &t1;
        p2 = &t2;
        p3 = &t3;

        Teacher *tmp;
        SeqList<Teacher *> list(10);
        list.insert(p1, 0);
        list.insert(p2, 0);
        list.insert(p3, 0);

        //测试链表的遍历
        for (int i = 0; i < 3; i++){
                list.get(i, tmp);
                cout<<tmp->age<<" ";
        }
        cout<<endl;

        //测试链表的销毁
        printf("开始删除元素\n");
        while ( list.getLen() > 0 ){
                list.del(0, tmp);
                cout<<tmp->age<<" ";
        }
        cout<<endl;
}

void seqInt()
{
        int a = 10, b = 20, c = 30, tmp;

        SeqList<int> list(10);
        list.insert(a, 0);
        list.insert(b, 0);
        list.insert(c, 0);

        //测试链表的遍历
        for (int i = 0; i < 3; i++){
                list.get(i, tmp);
                cout<<tmp<<" ";
        }
        cout<<endl;

        //测试链表的销毁
        printf("开始删除元素\n");
        while ( list.getLen() > 0 ){
                list.del(0, tmp);
                cout<<tmp<<" ";
        }
        cout<<endl;
}

int main(int argc, char const *argv[])
{
        seqTeacher();
       // seqTeacherPointers();
        //seqInt();
        return 0;
}
